package online.abor.springcloud.controller;

import online.abor.springcloud.entities.Dept;
import online.abor.springcloud.service.DeptClientService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class DeptController_Consumer {
    private final DeptClientService service;

    public DeptController_Consumer(DeptClientService service) {
        this.service = service;
    }
    @PostMapping("/consumer/dept/add")
    public boolean add(Dept dept) {
        return this.service.add(dept);
    }

    @GetMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id) {
        return this.service.get(id);
    }

    @GetMapping("/consumer/dept/list")
    public List<Dept> list() {
        return this.service.list();
    }

}
